﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dln.Common;
using Dln.Common.Helper;
using Dln.Handler;
using Dln.Model;
using Quartz;
namespace AutoRun
{
    public class SendInHospitalMoney : IJob
    {
        private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        public void Execute(IJobExecutionContext context)
        {
            log4net.Config.XmlConfigurator.Configure();
            Log.InfoFormat("SendInHospitalMoney The current time is: {0}", DateTime.Now);
            var patientInfoModel = SqlHelper.Context.From<PatientInfo>().Where(d => d.Delstatus == 0).ToList();
            if (patientInfoModel != null && patientInfoModel.Count > 0)
            {
                foreach (var item in patientInfoModel)
                {
                    //病人是否在院
                    object[] arge = new object[1];
                    arge[0] = item.PatientPatiID;
                    var url = CommonHelper.GetAppSettings("DlnService1");
                    object getCurrInHospNum = WebServiceHelper.InvokeWebService(url, "ISExistInHospital", arge);
                    if (getCurrInHospNum != null)
                    {
                        MessageHelper.ProblemNotice(item.Openid,
                                            "问题报修",
                                          DateTime.Now.AddDays(-1).ToString(),
                                           "问题报修",
                                           "标题:" + "昨日门诊收费详情",
                                            "http://www.healthyperson.cn/Page/AutoRun/SendProblem.aspx?Id=" + item.PatientIdCard
                                        );
                    }
                }

            }

            Log.InfoFormat("SendInHospitalMoney结束");
        }
    }
}
